//
//  SYDAccountTool.m
//  PinGJByOwnerSide
//
//  Created by lantaiyuan on 2017/9/22.
//  Copyright © 2017年 lantaiyuan. All rights reserved.
//

#import "SYDAccountTool.h"
#define SYDAccountPath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:@"account.archive"]
@implementation SYDAccountTool

/**
 *  存储用户的账号信息
 *
 *  @param account 登录模型
 */
+(void)saveAccount:(SYDAccount *)account{
    
    [NSKeyedArchiver archiveRootObject:account toFile:SYDAccountPath];
}


/**
 *  返回账号信息
 *
 *  @return 登录模型
 */
+(SYDAccount *)getAccount{
    SYDAccount *account = [NSKeyedUnarchiver unarchiveObjectWithFile:SYDAccountPath];
    return account;
}

+ (NSString *)getUserName{
    
    NSString *userName = [YMSaveTool objectForKey:@"userName"];
    return userName;
};

+ (NSString *)getPassword{
    
    NSString *passWord = [YMSaveTool objectForKey:@"passWord"];
    return passWord;
}

// 存储token
+(void)saveToken:(NSString *)token{
    
    [YMSaveTool setObject:token forKey:TOKEN_KEY];
}

// 读取token
+(NSString *)getToken{
    
    return [YMSaveTool objectForKey:TOKEN_KEY];
}

// 清空token
+(void)cleanToken{
  [YMSaveTool removeObjectForKey:TOKEN_KEY];
}

// 跟新token
+(LoginModel *)refreshToken{
    
    return nil;
}
// 存储时间
+(void)saveInvaildDate:(NSString *)invaildDate{
    [YMSaveTool setObject:invaildDate forKey:Invaild_KEY];
}

// 读取时间
+(NSString *)getInvaildDate{
    return [YMSaveTool objectForKey:Invaild_KEY];
}

// 清空时间
+(void)cleanInvaildDate{
    [YMSaveTool removeObjectForKey:Invaild_KEY];
}

// 跟新时间
+(NSString *)refreshInvaildDate{
    return nil;
}


@end
